//
//  BaseWebViewController.swift
//  AreaChainblock
//
//  Created by 赵佟越 on 2018/9/18.
//  Copyright © 2018年 zhaotongyue. All rights reserved.
//

import UIKit
import WebKit

class MyBaseWebViewController: BaseViewController ,WKNavigationDelegate,WKUIDelegate{
    var urlStr : NSString!

    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(self.webView)
        view.addSubview(self.progressView)
        // Do any additional setup after loading the view.
    }
    
    
    
    

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(false, animated: true)
        if UIDevice.current.isX() {
            self.progressView.frame = CGRect(x:0,y:88,width:self.view.frame.size.width,height:2)
        }else{
            self.progressView.frame = CGRect(x:0,y:64,width:self.view.frame.size.width,height:2)
        }
        
        
        self.progressView.isHidden = false
        UIView.animate(withDuration: 1.0) {
            self.progressView.progress = 0.0
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    lazy var webView : WKWebView = {
        let web = WKWebView( frame: CGRect(x:0, y:64,width:kScreenWidth, height:kScreenHeight))
        /// 设置访问的URL
        let url = NSURL(string: urlStr as String)
        /// 根据URL创建请求
        let requst = NSURLRequest(url: url! as URL)
        /// 设置代理
        //        web.uiDelegate = self
        web.navigationDelegate = self
        web.isOpaque = false;
        web.backgroundColor = UIColor.clear
        /// WKWebView加载请求
        web.load(requst as URLRequest)
        
        return web
    }()
    
    // 进度条
    lazy var progressView:UIProgressView = {
        let progress = UIProgressView()
        progress.progressTintColor = UIColor("909090")
        progress.trackTintColor = .clear
        return progress
    }()
    
   
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}




